

// debounce

function debounce(fn, time) {
    let timer = null
    return function (...args) {
        clearInterval(timer)
        // 注意 没有判断
        timer = setInterval(() => {
            fn.call(this, ...args)
        }, time)
    }
}

// trottle

function trottle(fn, time) {
    let timer = null
    return function (params) {
        if (!timer) {
            timer = setInterval(() => {
                fn.call(this, ...args)
                timer = null
            }, time);
        }
    }
}